import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data: data,
    handleError:true,
  })
}

export function getInfo(token) {
  return request({
    url: '/info',
    method: 'get',
  })
}

export function editMasterLogShow(data){
  return request({
    url:'/editMasterLogShow',
    method:'post',
    data:{
      ...data
    },
    handleError: true,
  })
}




export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

/**
 * 获取用户的店铺选项
 * @returns {Promise | Promise<unknown>}
 */
export function getUserOptions(){
  return request({
    url: '/user/getUserOptions'
  })
}

/**
 * 创建用户
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function createUser(data){
  return request({
    url: '/user/createUser',
    method: 'post',
    data,
    handleError: true,
  })
}

/**
 * 创建用户
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveEmpolye(data){
  return request({
    url: '/user/saveEmpolye',
    method: 'post',
    data,
    handleError: true,
  })
}
/**
 * 获取用户信息
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function getUserInfo(id){
  return request({
    url: `/user/getUserInfo/${id}`,
    method: 'get',
  })
}

/**
 * 保存用户信息
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function editUserInfo(data){
  return request({
    url: '/user/editUserInfo',
    method: 'post',
    data,
    handleError: true,
  })
}
/**
 * 保存用户信息
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveUserInfo(data){
  return request({
    url: '/user/saveUserInfo',
    method: 'post',
    data,
    handleError: true,
  })
}

/**
 * 修改用户备注
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function saveUserRemark(params){
  return request({
    url: `/user/saveUserRemark/${params.id}`,
    params,
    method: 'patch'
  })
}

/**
 * 获取用户列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getUserList(params = {}){
  return request({
    url: `/user/getUserList`,
    params,
    method: 'get',
  })
}

/**
 * 获取用户列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getEmpolye(params = {}){
  return request({
    url: `/user/getEmpolye`,
    params,
    method: 'get',
  })
}
/**
 * 改变用户的权限
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function changeUserAdmin(data){
  return request({
    url: `/user/changeUserAdmin`,
    data,
    method: 'put',
    handleError: true,
  })
}

/**
 * 获取登录的链接
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function getUserLoginWithKey(id){
  return request({
    url: `/user/getUserLoginWithKey/${id}`,
    method: 'get'
  })
}

/**
 * 获取充值记录列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getRechargeRecordData(params){
  return request({
    url: '/user/getRechargeRecordData',
    params,
  })
}

/**
 * 保存用户的隐藏订单数据
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveUserOrderHidden(data){
  return request({
    url: '/user/saveUserOrderHidden',
    method: 'post',
    data,
    handleError: true,
  })
}
/*

 */
export function getIsShowLog(params){
  return request({
    url: `/getIsShowLog`,
    method: 'get',
    params:{
      ...params
    }
  })
}
